/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bill.model.vo;

import java.util.ArrayList;

/**
 *
 * @author Administrator
 */
public class CompGroup {

    private String cGroupCode;
    
    private String cGroupName;
    
    private byte iGroupType;

    private ArrayList<CompUnit> units =
            new ArrayList<CompUnit>();

    //private Map<String,CompUnit> units = new HashMap<String,CompUnit>();

    public CompGroup(){}

    public CompGroup(String cGroupCode,String cGroupName,byte iGroupType){
        this.cGroupCode = cGroupCode;
        this.cGroupName = cGroupName;
        this.iGroupType = iGroupType;
    }

    /**
     * @return the cGroupCode
     */
    public String getcGroupCode() {
        return cGroupCode;
    }

    /**
     * @param cGroupCode the cGroupCode to set
     */
    public void setcGroupCode(String cGroupCode) {
        this.cGroupCode = cGroupCode;
    }

    /**
     * @return the cGroupName
     */
    public String getcGroupName() {
        return cGroupName;
    }

    /**
     * @param cGroupName the cGroupName to set
     */
    public void setcGroupName(String cGroupName) {
        this.cGroupName = cGroupName;
    }

    /**
     * @return the iGroupType
     */
    public byte getiGroupType() {
        return iGroupType;
    }

    /**
     * @param iGroupType the iGroupType to set
     */
    public void setiGroupType(byte iGroupType) {
        this.iGroupType = iGroupType;
    }
    
    /*public void setUnits(HashMap<String,CompUnit> units){
        this.units = units;
    }

    public Map<String,CompUnit> getUnits(){
        return this.units;
    }*/

    public void setUnits(ArrayList<CompUnit> units){
        this.units = units;
    }

    public ArrayList<CompUnit> getUnits(){
        return this.units;
    }

    public void addUnit(CompUnit unit){
        //units.put(unit.getcComunitCode(), unit);
        units.add(unit);
    }

    public CompUnit getUnitByCompUnitCode(String CompUnitCode){
        CompUnit compUnit = null;
        for(CompUnit cu : units){
            if(cu.getcComunitCode().equals(CompUnitCode)){
                compUnit = cu;
                break;
            }
        }
        return compUnit;
    }

    public void updateFirstCompUnit(String compUnitCode){
        units.get(0).setcComunitCode(compUnitCode);
    }
}
